Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The coupon is not valid and discount is not applied #4409

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

fabianaromagnoli
Copy link

@fabianaromagnoli fabianaromagnoli commented Dec 9, 2024

It solves the issue reported here #4401.

Preconditions
OpenMage version 20.6.0
PHP 8.0

Steps to reproduce
Setup a cart promo rule with a specific coupon. Set both start date and end date with current date.
Go to fronted, add a product to cart and go to the cart page
Try to apply the coupon

Expected result
The coupon is valid and discount is applied

Actual result
The coupon is not valid and discount is not applied

In this piece of code the coupon expiration date is compared to the current datetime, but coupon expiration date always has 00:00:00 time, so that if the expiration day is today, that check cannot pass. Dates should be compared without considering time, like it's done in the Collection where the promo validity dates are compared to $now, and $now is a date without time.

@github-actions github-actions bot added the Component: SalesRule Relates to Mage_SalesRule label Dec 9, 2024
@addison74 addison74 linked an issue Dec 9, 2024 that may be closed by this pull request
@addison74 addison74 changed the title Fix issue #4401 The coupon is not valid and discount is not applied Dec 9, 2024
@sreichel
Copy link
Contributor

Id change the code to not call getExpirationDate before hasExpirationDate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: SalesRule Relates to Mage_SalesRule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coupon not valid when cart promo rule end date is today.
2 participants